<?php
declare (strict_types=1);

use think\facade\Route;

Route::group('promotion', function () {
    // 区分类型
    Route::group('<type>', function () {
        // 列表
        Route::get('list', '@index');
        // 创建
        Route::rule('create', '@create', 'GET|POST');
        Route::rule('<id>/edit', '@edit', 'GET|PUT')->pattern(['id' => '\d+']);
        // 活动报表
        Route::get('<id>/report$', '@report')->pattern(['id' => '\d+']);
        // 帮砍价详情
        Route::get('<id>/report/<bargain_id>/bargain', '@reportBargainInfo')->pattern(['id' => '\d+', 'bargain_id' => '\d+']);
        // 拼团详情
        Route::get('<id>/report/<tuan_id>/tuan', '@reportTuanInfo')->pattern(['id' => '\d+', 'tuan_id' => '\d+']);
    })->pattern(['type' => '[a-zA-Z_]+']);

    // 通用
    Route::group('<id>', function () {
        // 编辑指定字段
        Route::put('edit/<field>$', '@editField');
        // 删除
        Route::delete('delete', '@delete');
    })->pattern(['id' => '\d+', 'field' => '[a-zA-Z_]+']);

})->prefix(\app\admin\service\promotion\Promotion::class);